package bmark

import grails.test.*

class BookmarkServiceTests extends GrailsUnitTestCase {
    def bookmarkService
    protected void setUp() {
        super.setUp()
        bookmarkService = new BookmarkService()
        mockDomain(Bookmark)
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testSaveValidBookmark() {
        def bookmark = new Bookmark(url:'http://www.google.com')

        assertTrue bookmarkService.saveBookmark(bookmark)
        assertEquals 1, Bookmark.count()
    }

    void testSaveCompletedBookmark() {
        def bookmark = new Bookmark(url:'www.google.com')

        assertTrue bookmarkService.saveBookmark(bookmark)
        assertEquals 1, Bookmark.count()
    }

    void testSaveInvalidBookmarkShouldReturnFalse() {
        def bookmark = new Bookmark(url:'http://www.foo.bar')

        assertFalse bookmarkService.saveBookmark(bookmark)
        assertEquals 0, Bookmark.count()
    }
}
